package com.kaifamiao.www.demo.Do21;

public class De06 {
    public static void main(String[] args) {
        //插入数字
        int[] arr = {1,11,12,21,13,31,14};
        int index = 2;
        int num = 10;
        //插入后数组的长度是原来的长度+1.
        int[]newArr = new int[arr.length+1];
        //将原来的数组复制到新的数组中
        System.arraycopy(arr,0,newArr,0,arr.length);
        //在新的数组中插入数字
        System.arraycopy(newArr,index,newArr,index+1,newArr.length-index-1);
        newArr[index] = num;
        for(int i = 0;i < newArr.length;i++){
            System.out.println(newArr[i]);
        }
    }
}
